const sequelize = require("../app/db");
const { DataTypes, Model } = require("sequelize");

class UserCollect extends Model {}
UserCollect.init(
  {
    Id: {
      type: DataTypes.INTEGER,
      allowNull: false, //不允许为空
      primaryKey: true,
      autoIncrement: true,
    },
    UserId: {
      type: DataTypes.INTEGER,
    },
    ResourceId: {
      type: DataTypes.INTEGER,
    },
    ResourceType: {
      type: DataTypes.INTEGER,
    },
    CreateTime: {
      type: DataTypes.STRING,
      get() {
        return new Date(this.getDataValue("CreateTime")).getTime();
      },
    },
  },
  {
    sequelize,
    modelName: "UserCollect",
    tableName: "user_collect", //强制设置表名
  }
);

module.exports = UserCollect;
